package com.pointi.emoTools;

public class bdLog
{
	public static final int LOG_FULL = 0 ;
	public static final int LOG_AGENT = 1 ;
	public static final int LOG_CUSTOMER = 2 ;

	// ________________________________
	// t_bd_????_log_yyyymm // common

	private int callkey ;
	private double ai ; // Anger Index
	private double ni ; // Neutral Index
	private double ei ; // Neutral Index
	private int tc ; // Talk Count
	private int tt ; // Talk Time
	private double ttr ; // Talk Time Ratio
	private int tgc ;
	private int tgt ;
	private double tgtr ;
	private int mc ; // Mute Count
	private int mt ; // Mute Time
	private double mtr ; // Mute Time Ratio

	private int dur ;
	private int ht ;
	private int td ;
	private int section ; 

	// ______________________________
	// t_bd_full_log_yyyymm // only

	private int oc ; // Overlap Count
	private int ot ; // Overlap Time
	private double otr ; // Overlap Time Ratio

	public bdLog()
	{
		//
	}

	public void fnInitialize(int callkey, int section, int dur, int ht, int td)
	{
		this.callkey = callkey ;
		this.dur = dur ;
		this.ht = ht ;
		this.td = td ;
		ai = 0 ;
		ni = 0 ;
		ei = 0 ;
		tc = 0 ;
		tt = 0 ;
		ttr = 0 ;
		tgc = 0 ;
		tgt = 0 ;
		tgtr = 0 ;
		mc = 0 ;
		mt = 0 ;
		mtr = 0 ;
		this.section = section ;
	}

	public void callkey(int callkey) { this.callkey = callkey ; }
	public void dur(int dur) { this.dur = dur ; }
	public void ht(int ht) { this.ht = ht ; }
	public void td(int td) { this.td = td ; }
	public void ai(double ai) { this.ai = ai ; }
	public void ni(double ni) { this.ni = ni ; }
	public void ei(double ei) { this.ei = ei ; }
	public void tc(int tc) { this.tc = tc ; }
	public void tt(int tt) { this.tt = tt ; }
	public void tgc(int tgc) { this.tgc = tgc ; }
	public void tgt(int tgt) { this.tgt = tgt ; }
	public void mc(int mc) { this.mc = mc ; }
	public void mt(int mt) { this.mt = mt ; }
	public void oc(int oc) { this.oc = oc ; }
	public void ot(int ot) { this.ot = ot ; }

	public int callkey() { return callkey ; }
	public int dur() { return dur ; }
	public int ht() { return ht ; }
	public int td() { return td ; }
	public double ai() { return ai ; }
	public double ni() { return ni ; }
	public double ei() { return ei ; }
	public int tc() { return tc ; }
	public int tt() { return tt ; }
	public double ttr() { return ttr ; }
	public int tgc() { return tgc ; }
	public int tgt() { return tgt ; }
	public double tgtr() { return tgtr ; }
	public int mc() { return mc ; }
	public int mt() { return mt ; }
	public double mtr() { return mtr ; }
	public int oc() { return oc ; }
	public int ot() { return ot ; }
	public double otr() { return otr ; }
	public int section() { return section ; }
	
	// ADD
	public void addtc() { this.tc++ ; }
	public void addtt(int tt) { this.tt += tt ; }
	public void addtgc() { this.tgc++ ; }
	public void addtgt(int tgt) { this.tgt += tgt ; }
	public void addmc(int mc) { this.mc += mc ; }
	public void addmt(int mt) { this.mt += mt ; }
	public void setTD(int td)
	{
		ttr = (double)tt * 100 / (double)td ;
		tgtr = (double)tgt * 100 / (double)td ;
		mtr = (double)mt * 100 / (double)td ;
		if (ot != 0) { otr = (double)ot * 100 / (double)td ; }
	}

	public String fnGetQuery(String inDate, int option)
	{
		String query = "" ;
		if(option == bdLog.LOG_FULL)
		{
			query = "INSERT INTO t_bd_full_log_" + inDate + " (" +
					" callkey , " +
					" dur , " +
					" ht , " +
					" td , " +
					" ai , " +
					" ni , " +
					" ei , " +
					" tc , " +
					" tt , " +
					" ttr , " +
					" tgc , " +
					" tgt , " +
					" tgtr , " +
					" mc , " +
					" mt , " +
					" mtr , " +
					" oc , " +
					" ot , " +
					" otr " +
					") VALUES (" +
					callkey + ", " + 
					dur + ", " + 
					ht + ", " + 
					td + ", " + 
					ai + ", " + 
					ni + ", " + 
					ei + ", " + 
					tc + ", " + 
					tt + ", " + 
					ttr + ", " + 
					tgc + ", " + 
					tgt + ", " + 
					tgtr + ", " + 
					mc + ", " + 
					mt + ", " + 
					mtr + ", " + 
					oc + ", " + 
					ot + ", " + 
					otr + ") ;" ;
		}
		else
		{
			String table_name = "t_bd_agent_log_" ;
			if(option == bdLog.LOG_CUSTOMER) table_name = "t_bd_customer_log_" ;
			query = "INSERT INTO " + table_name + inDate + " (" +
					" callkey , " +
					" dur , " +
					" ht , " +
					" td , " +
					" ai , " +
					" ni , " +
					" ei , " +
					" tc , " +
					" tt , " +
					" ttr , " +
					" tgc , " +
					" tgt , " +
					" tgtr , " +
					" mc , " +
					" mt , " +
					" mtr " +
					") VALUES (" +
					callkey + ", " + 
					dur + ", " + 
					ht + ", " + 
					td + ", " + 
					ai + ", " + 
					ni + ", " + 
					ei + ", " + 
					tc + ", " + 
					tt + ", " + 
					ttr + ", " + 
					tgc + ", " + 
					tgt + ", " + 
					tgtr + ", " + 
					mc + ", " + 
					mt + ", " + 
					mtr + ") ;" ;
		}
		return query ;
	}
}
